package com.xhs.zdl.demo.addressChoose;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.xhs.zdl.demo.R;

public class ChooseAddressActivity extends AppCompatActivity {

    private Button btn;
    private TextView vaule;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_choose_address);

        findView();
        initView();
    }

    private void findView() {
        btn = (Button) findViewById(R.id.choose_btn);
        vaule = (TextView) findViewById(R.id.choose_value);
    }

    private void initView() {
        btn.setOnClickListener(onClickListener);
    }

    View.OnClickListener onClickListener = new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            switch (view.getId()){
                case R.id.choose_btn:
                    startActivityForResult(new Intent(ChooseAddressActivity.this, AreaSelectActivity.class), 1);
                    break;
            }
        }
    };

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode == RESULT_OK){
            vaule.setText(data.getStringExtra("data"));
            data.getStringExtra("data");
        }
    }
}
